//
//  SetPasswordView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2024/12/26.
//

import SwiftUI

struct SetPasswordView: View {
    @EnvironmentObject var themeManager: ThemeManager
    @EnvironmentObject var appStorageManager: AppStorageManager
    var body: some View {
        HStack{
            VStack(alignment: .leading, spacing: 10) {
                Text("密码模块")
                    .foregroundColor(.bgItemContent)
                    .fontWeight(.bold)
                    .font(.system(size: 14))
                Toggle("锁屏密码", isOn: appStorageManager.$togglePassword)
                    .foregroundColor(.bgItemContent)
                    .toggleStyle(SwitchToggleStyle(tint: themeManager.themeColor))
                    .font(.system(size: 14))
                Toggle("面容解锁", isOn: appStorageManager.$toggleFace)
                    .foregroundColor(.bgItemContent)
                    .toggleStyle(SwitchToggleStyle(tint: themeManager.themeColor))
                    .font(.system(size: 14))
                    .disabled(!appStorageManager.togglePassword) // 禁用用户交互
                    .opacity(appStorageManager.togglePassword ? 1 : 0.3)
                HStack {
                     Text("修改密码")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                     Spacer()
                     Image(systemName: "arrow.right.circle.fill")
                         .resizable()
                         .scaledToFit()
                         .foregroundColor(.gray.opacity(0.5))
                         .frame(width: 15, height: 15)
                         .clipped()
                }.padding(.top,5).padding(.bottom,5)
                HStack {
                     Text("找回密码配置")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                     Spacer()
                    Image(systemName: "arrow.right.circle.fill")
                        .resizable()
                        .scaledToFit()
                        .foregroundColor(.gray.opacity(0.5))
                        .frame(width: 15, height: 15)
                        .clipped()
                }.padding(.top,5).padding(.bottom,5)
                HStack {
                     Text("修改密码")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                     Spacer()
                    Image(systemName: "arrow.right.circle.fill")
                        .resizable()
                        .scaledToFit()
                        .foregroundColor(.gray.opacity(0.5))
                        .frame(width: 15, height: 15)
                        .clipped()
                }.padding(.top,5).padding(.bottom,5)
            }
            Spacer()
        }.frame(maxWidth: .infinity).padding().background(.bgItem).clipShape(RoundedRectangle(cornerRadius: 15))
    }
}

//#Preview {
//    SetPasswordView()
//}

//定义预览提供者
struct SetPassword_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: SetPasswordView())
    }
}
